Example #1
0
        public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.
                                                ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Tracer.Listeners.Add(new System.Diagnostics.EventLogTraceListener("Application"));

            Autodesk.Revit.UI.UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document doc = uidoc.Document;

            try {
                IList <Wall> walls = new FilteredElementCollector(doc)
                                     .OfClass(typeof(Wall))
                                     .WhereElementIsNotElementType()
                                     .Cast <Wall>()
                                     .ToList();

                Tracer.Write("All the walls in the project: " + walls.Count);

                foreach (Wall wall in walls)
                {
                    IList <Element> intrudingWalls =
                        GetWallsIntersectBoundingBox(doc, wall);

                    Tracer.Write(string.Format("Wall {0} is intersected by {1} walls",
                                               wall.Id.ToString(), intrudingWalls.Count));

                    using (Transaction t = new Transaction(doc, "Join walls")) {
                        t.Start();
                        foreach (Element elem in intrudingWalls)
                        {
                            if (((Wall)elem).WallType.Kind == WallKind.Curtain)
                            {
                                continue;
                            }
                            try {
                                if (!JoinGeometryUtils.AreElementsJoined(doc, wall, elem))
                                {
                                    JoinGeometryUtils.JoinGeometry(doc, wall, elem);
                                }
                            }
                            catch (Exception ex) {
                                Tracer.Write(string.Format("{0}\nWall: {1} cannot be joined to {2}",
                                                           ex.Message, wall.Id.ToString(), elem.Id.ToString()));
                                continue;
                            }
                        }
                        t.Commit();
                    }
                }

                return(Autodesk.Revit.UI.Result.Succeeded);
            }
            catch (Autodesk.Revit.Exceptions.OperationCanceledException) {
                return(Autodesk.Revit.UI.Result.Cancelled);
            }
            catch (Exception ex) {
                Tracer.Write(string.Format("{0}\n{1}",
                                           ex.Message, ex.StackTrace));
                return(Autodesk.Revit.UI.Result.Failed);
            }
        }
Example #2
0
        static void SelectByAssemblyMarks(IList <Element> rebars, IList <string> asmMarks)
        {
            // Filter out the rebars by assembly
            IList <Element> selectedAssemblies = new List <Element>();

            IEnumerator <Element> itr = rebars.GetEnumerator();

            while (itr.MoveNext())
            {
                Element curElem    = itr.Current;
                string  curAsmMark = curElem
                                     .LookupParameter(ASSEMBLY_MARK).AsString();

                if (curAsmMark != null)
                {
                    if (asmMarks.Contains(curAsmMark))
                    {
                        selectedAssemblies.Add(curElem);
                    }
                }
            }
            Trace.Write("By partition and host mark and assemblies: " +
                        selectedAssemblies.Count);

            rebars = selectedAssemblies;
        }
Example #3
0
        private void addGroups(SPWeb curWeb)
        {
            var arrGTemp = new SortedList();

            processList(curWeb, arrGTemp);

            var timeSpan = periodEnd - periodStart;

            foreach (DictionaryEntry entry in arrGTemp)
            {
                var newItem   = entry.Key.ToString();
                var parentInd = newItem.LastIndexOf("\n");
                var parent    = string.Empty;

                if (parentInd >= 0)
                {
                    parent  = newItem.Substring(0, parentInd);
                    newItem = newItem.Substring(parentInd + 1);
                }

                if ((hshItemNodes.Contains(parent) && !hshItemNodes.Contains(entry.Key.ToString())) ||
                    (parentInd == -1 && !hshItemNodes.Contains(entry.Key.ToString())))
                {
                    var parentNode = parentInd == -1
                        ? ndMainParent
                        : (XmlNode)hshItemNodes[parent];

                    var newNode = docXml.CreateNode(XmlNodeType.Element, Row, docXml.NamespaceURI);
                    AppendChilds(entry.Key.ToString(), newItem, parentNode, newNode);

                    for (var i = 0; i <= timeSpan.Days; i++)
                    {
                        var showDay = string.Empty;
                        try
                        {
                            showDay = dayDefs[(int)periodStart.AddDays(i).DayOfWeek * 3];
                        }
                        catch (Exception ex)
                        {
                            SystemTrace.WriteLine(ex.ToString());
                        }
                        if (showDay == True)
                        {
                            AppendChild(newNode, string.Empty);
                        }
                    }

                    hshItemNodes.Add(entry.Key.ToString(), newNode);
                }
            }

            while (queueAllItems.Count > 0)
            {
                var listItem = (SPListItem)queueAllItems.Dequeue();
                if (arrItems.Contains(listItem.ID.ToString()))
                {
                    ProcessListItem(curWeb, timeSpan, listItem);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Logs an exception and its context to the error log.
        /// </summary>

        protected virtual void LogException(Exception e, HttpContext context)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            try
            {
                this.ErrorLog.Log(new Error(e, context));
            }
            catch (Exception localException)
            {
                //
                // IMPORTANT! We swallow any exception raised during the
                // logging and send them out to the trace . The idea
                // here is that logging of exceptions by itself should not
                // be  critical to the overall operation of the application.
                // The bad thing is that we catch ANY kind of exception,
                // even system ones and potentially let them slip by.
                //

                Trace.WriteLine(localException);
            }
        }
Example #5
0
        private void ProcessNodes(
            TimeSpan timeSpan,
            string listItemId,
            string resName,
            string realName,
            string loginName,
            DataRow[] dataRows,
            string groupName,
            int parentInd,
            string parent)
        {
            if (dataRows == null)
            {
                throw new ArgumentNullException(nameof(dataRows));
            }

            var parentNode = parentInd == -1
                ? ndMainParent
                : (XmlNode)hshItemNodes[parent];

            var newNode = docXml.CreateNode(XmlNodeType.Element, Row, docXml.NamespaceURI);

            AppendChilds(listItemId, resName, realName, dataRows, parentNode, newNode);

            for (var days = 0; days <= timeSpan.Days; days++)
            {
                var showDay = string.Empty;
                try
                {
                    showDay = dayDefs[(int)periodStart.AddDays(days).DayOfWeek * 3];
                }
                catch (Exception ex)
                {
                    SystemTrace.WriteLine(ex.ToString());
                }
                if (showDay == True)
                {
                    AppendChild(newNode, string.Empty);
                }
            }

            var drTasks = dsTimesheetTasks.Tables[0].Select("ts_uid = '" + dataRows[0][TsUid] + "'");
            var regex   = new Regex("[^0-9a-zA-Z]+", RegexOptions.Compiled);

            curProject = null;
            foreach (var drTask in drTasks)
            {
                ProcessTask(timeSpan, listItemId, newNode, regex, drTask);
            }

            if (!hshItemNodes.Contains(groupName))
            {
                hshItemNodes.Add(groupName, newNode);
            }

            if (!hshResNodes.Contains(loginName))
            {
                hshResNodes.Add(loginName, newNode);
            }
        }
Example #6
0
        public void Test_Vagrant_Connect()
        {
            SshConnectionInfo input = UserInput;

            SshShell shell = new SshShell(input.Host, input.User);

            if (input.Pass != null)
            {
                shell.Password = input.Pass;
            }
            if (input.IdentityFile != null)
            {
                shell.AddIdentityFile(input.IdentityFile);
            }

            //This statement must be prior to connecting
            shell.RedirectToConsole();

            Console.Write("Connecting...");
            shell.Connect();
            Console.WriteLine("OK");

            // SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
            Console.WriteLine("server=" + shell.ServerVersion);

            SshExec shellExec = null;

            if (shell.ShellOpened)
            {
                // shell.Close();

                shellExec = SshExec.Clone(shell);
                // new SshExec(shell.Host, shell.Username, shell.Password);
                shellExec.Connect();
            }

            if (shellExec != null && shellExec.Connected)
            {
                var session = shellExec.Session;
                var channel = shellExec.Channel;
                Console.WriteLine(session);
                Console.WriteLine(channel);

                var stream = shellExec.RunCommandEx("ls -l", true);
                // = shell.StreamASCII();
                while (stream.MoveNext())
                {
                    Console.WriteLine(stream.Current);
                }

                System.Threading.Thread.Sleep(500);
            }

            Console.Write("Disconnecting...");
            if (shellExec != null)
            {
                shellExec.Close();
            }
            Console.WriteLine("OK");
        }
        private IList <SPEventReceiverDefinition> GetListEvents(
            SPList list,
            string assemblyName,
            string className,
            IList <SPEventReceiverType> types)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }
            if (types == null)
            {
                throw new ArgumentNullException(nameof(types));
            }
            var events = new List <SPEventReceiverDefinition>();

            try
            {
                events = (from e in list.EventReceivers.OfType <SPEventReceiverDefinition>()
                          where e.Assembly.Equals(assemblyName, StringComparison.CurrentCultureIgnoreCase) &&
                          e.Class.Equals(className, StringComparison.CurrentCultureIgnoreCase) &&
                          types.Contains(e.Type)
                          select e).ToList();
            }
            catch (Exception ex)
            {
                SystemTrace.WriteLine((ex.ToString()));
            }

            return(events);
        }
Example #8
0
        private void GetHoursTotal(XmlNode newCell, DataRow[] drTaskTimes, DataRow[] drTaskNotes, out double total, out string hours)
        {
            if (drTaskTimes == null)
            {
                throw new ArgumentNullException(nameof(drTaskTimes));
            }

            if (drTaskNotes == null)
            {
                throw new ArgumentNullException(nameof(drTaskNotes));
            }

            total = 0;
            hours = drTaskTimes.Length > 0
                ? drTaskTimes[0][Hours].ToString()
                : Zero;

            if (!double.TryParse(hours, out total))
            {
                SystemTrace.WriteLine($"Unable to parse double from string '{hours}'");
            }

            if (drTaskNotes.Length > 0)
            {
                AppendAttribute(newCell, TypeConst, TimeEditor);

                hours = "0|" + hours + "|N|" + drTaskNotes[0][TsItemNotes];
            }
        }
        private void addHeader(SPWeb curWeb)
        {
            var ndHead = docXml.CreateNode(XmlNodeType.Element, "head", docXml.NamespaceURI);

            docXml.ChildNodes[0].AppendChild(ndHead);
            ndBeforeInit = docXml.CreateNode(XmlNodeType.Element, "beforeInit", docXml.NamespaceURI);
            ndHead.AppendChild(ndBeforeInit);
            var afterInitNode = docXml.CreateNode(XmlNodeType.Element, "afterInit", docXml.NamespaceURI);

            ndHead.AppendChild(afterInitNode);

            AddColumns(ndHead);

            var sql = "select period_start,period_end,locked from TSPERIOD where period_id=@period_id and site_id=@siteid";

            using (var cmd = new SqlCommand(sql, cn))
            {
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@period_id", period);
                cmd.Parameters.AddWithValue("@siteid", curWeb.Site.ID);
                using (var dataReader = cmd.ExecuteReader())
                {
                    if (dataReader.Read())
                    {
                        periodStart = dataReader.GetDateTime(0);
                        periodEnd   = dataReader.GetDateTime(1);
                    }
                }
            }

            dayDefs = CoreFunctions.getConfigSetting(curWeb.Site.RootWeb, "EPMLiveDaySettings").Split('|');

            var timeSpan = periodEnd - periodStart;

            for (var day = 0; day <= timeSpan.Days; day++)
            {
                var showDay = string.Empty;
                try
                {
                    showDay = dayDefs[(int)periodStart.AddDays(day).DayOfWeek * 3];
                }
                catch (Exception ex)
                {
                    SystemTrace.WriteLine(ex.ToString());
                }
                if (showDay == True)
                {
                    var newCol = AddNewColumn(day);

                    ndHead.AppendChild(newCol);
                }
            }

            var newColumn = AddNewColumn();

            ndHead.AppendChild(newColumn);

            InitializeTimSheets(curWeb.Site.ID);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var web = SPContext.Current.Web;
                lblSiteId.Text = web.Site.ID.ToString();
                lblWebId.Text  = web.ID.ToString();
                AddMasterPages(web);

                chkDisablePublishing.Checked = CoreFunctions.getConfigSetting(web, "EPMLiveDisablePublishing") == bool.TrueString
                    ? true
                    : false;
                TrySetCheckedProperty(web, chkDisablePlanners, "EPMLiveDisablePlanners");
                TrySetCheckedProperty(web, chkDisableContextualSlideouts, "EPMLiveDisableContextualSlideouts");

                try
                {
                    tbPublicCommentDefaultTxt.Text = CoreFunctions.getConfigSetting(web, "EPMLivePublicCommentText");
                }
                catch (Exception ex)
                {
                    SysTrace.WriteLine(ex);
                }

                SetProductAdditionalInfo(web);
                UpdateAllowSynch(web);

                foreach (SPList list in web.Lists)
                {
                    if (!list.Hidden)
                    {
                        ddlResources.Items.Add(list.Title);
                    }
                }
                try
                {
                    ddlResources.SelectedValue = CoreFunctions.getConfigSetting(web, "EPMLiveResourcePool");
                }
                catch (Exception ex)
                {
                    SysTrace.WriteLine(ex);
                }

                if (web.ServerRelativeUrl.Equals(CoreFunctions.getConfigSetting(web, "EPMLiveResourceURL"), StringComparison.InvariantCultureIgnoreCase))
                {
                    pnlResources.Visible = true;
                }

                if (web.Properties.ContainsKey("TemplateVersion"))
                {
                    txtVersion.Text = $"v {web.Properties["TemplateVersion"]}";
                }

                MarkArchivedPersonalizationsChecked(web);
                cbDisableMyWorkspaces.Checked  = GetConfigSettingIfNotEmpty(web, "EPMLiveDisableMyWorkspaces");
                cbDisableCommonActions.Checked = GetConfigSettingIfNotEmpty(web, "EPMLiveDisableCommonActions");
                cbDisableCreateNew.Checked     = GetConfigSettingIfNotEmpty(web, "EPMLiveDisableCreateNew");
            }
        }
Example #11
0
        private string FilterHead(
            TimeSpan timeSpan,
            string[] dayDefs,
            DateTime dtStart,
            string filterHead,
            ArrayList arrayList,
            bool timeEditor,
            ref int colCount)
        {
            Guard.ArgumentIsNotNull(arrayList, nameof(arrayList));
            Guard.ArgumentIsNotNull(filterHead, nameof(filterHead));
            Guard.ArgumentIsNotNull(dayDefs, nameof(dayDefs));

            var filterHeadBuilder = new StringBuilder(filterHead);

            for (var i = 0; i <= timeSpan.Days; i++)
            {
                var showDay = string.Empty;

                try
                {
                    showDay = dayDefs[(int)dtStart.AddDays(i).DayOfWeek * 3];
                }
                catch (Exception exception)
                {
                    DiagTrace.WriteLine(exception);
                }

                if (showDay == TrueText)
                {
                    filterHeadBuilder.Append(",&nbsp;");
                    colCount++;
                    arrayList.Add(dtStart.AddDays(i));
                    var newCol = docXml.CreateNode(XmlNodeType.Element, ColumnText, docXml.NamespaceURI);
                    newCol.InnerXml = $"<![CDATA[{dtStart.AddDays(i).DayOfWeek.ToString().Substring(0, 3)}<br>{dtStart.AddDays(i).Day}]]>";
                    var attrType = docXml.CreateAttribute(TypeText);

                    attrType.Value = timeEditor
                        ? "timeeditor"
                        : "edn";

                    var attrWidth = docXml.CreateAttribute(WidthText);
                    attrWidth.Value = "40";
                    var attrAlign = docXml.CreateAttribute(AlignText);
                    attrAlign.Value = "right";
                    var attrId1 = docXml.CreateAttribute(IdText);
                    attrId1.Value = $"_TsDate_{dtStart.AddDays(i).ToShortDateString().Replace("/", "_")}";

                    newCol.Attributes.Append(attrType);
                    newCol.Attributes.Append(attrWidth);
                    newCol.Attributes.Append(attrAlign);
                    newCol.Attributes.Append(attrId1);

                    docXml.SelectSingleNode(SingleNodePath).AppendChild(newCol);
                }
            }

            return(filterHeadBuilder.ToString());
        }
Example #12
0
        void GroupRebars(IList <FamilyInstance> filteredRebars)
        {
            // Group the rebars into three categories and mark them
            var rebarType1 = from fi in filteredRebars
                             where fi.Symbol.FamilyName.Contains(RebarsUtils.STRAIGHT) ||
                             fi.Symbol.FamilyName.Contains(RebarsUtils.EXTRA) ||
                             fi.Symbol.FamilyName.Contains(RebarsUtils.POINT)
                             select fi;

            Tracer.Write("RT1 = " + rebarType1.Count());

            // Mark the first category
            if (rebarType1.Count() != 0)
            {
                MarkRebarType1(rebarType1.ToList());
            }

            var rebarType2 = from fi in filteredRebars
                             where fi.Symbol.FamilyName.Contains(RebarsUtils.BACKGROUND)
                             select fi;

            Tracer.Write("RT2 = " + rebarType2.Count());

            // Mark the second category
            if (rebarType2.Count() != 0)
            {
                MarkRebarType2(rebarType2.ToList());
            }

            var rebarType3 = from fi in filteredRebars
                             where
                             !fi.Symbol.FamilyName.StartsWith("R-EMP") &&
                             !fi.Symbol.FamilyName.Contains(RebarsUtils.STRAIGHT) &&
                             !fi.Symbol.FamilyName.Contains(RebarsUtils.POINT) &&
                             !fi.Symbol.FamilyName.Contains(RebarsUtils.EXTRA) &&
                             !fi.Symbol.FamilyName.Contains(RebarsUtils.BACKGROUND)
                             select fi;

            Tracer.Write("RT3 = " + rebarType3.Count());

            // Mark the third category
            if (rebarType3.Count() != 0)
            {
                GroupAndMarkRebarT3(rebarType3.ToList());
            }

            var rebarType4 = from fi in filteredRebars
                             where
                             fi.Symbol.FamilyName.StartsWith("R-EMP")
                             select fi;

            Tracer.Write("RT4 = " + rebarType4.Count());

            // Mark the forth type
            if (rebarType4.Count() != 0)
            {
                GroupMarkRebarType4(rebarType4.ToList());
            }
        }
        protected void AuditWebs()
        {
            SPList spList = null;

            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (var spSite = new SPSite(_SiteID))
                {
                    foreach (SPWeb spWeb in spSite.AllWebs)
                    {
                        using (spWeb)
                        {
                            spWeb.AllowUnsafeUpdates = true;
                            spList = null;
                            try
                            {
                                // List may not always be present. IF NOT PRESENT, error will be caught.
                                spList = spWeb.Lists[_sListName];
                            }
                            catch (Exception ex)
                            {
                                SystemTrace.WriteLine(ex.ToString());
                            }

                            if (spList != null)
                            {
                                AuditWebs(spList.EventReceivers, spSite.RootWeb.Url, spWeb.Url, spWeb.ServerRelativeUrl);
                            }
                            else
                            {
                                // Report "List Not Present" error
                                AddAuditRecord("List Not Present.", _sListName, spWeb.ServerRelativeUrl);
                            }
                            spWeb.AllowUnsafeUpdates = false;
                        }
                    }
                }
            });

            if (_dtAuditRecs.Rows.Count > 0)
            {
                grdVwResults.ID                  = "grdVwResults";
                grdVwResults.RowCreated         += grdVwResults_RowCreated;
                grdVwResults.DataSource          = _dtAuditRecs;
                grdVwResults.AutoGenerateColumns = false;
                grdVwResults.DataBind();
            }
            else
            {
                var label = new Label
                {
                    Text = "All webs up to date."
                };
                grdVwResults.Visible = false;
                var masterPage  = Master;
                var placeHolder = (ContentPlaceHolder)masterPage.FindControl(PlaceHolderId);
                placeHolder.Controls.Add(label);
            }
        }
Example #14
0
 /// <summary>Wraps an Exsisting instance of an object</summary>
 /// <param name="o">Instance of the object to wrap</param>
 public static Microsoft.Test.Security.Wrappers.TraceSW Wrap(System.Diagnostics.Trace o)
 {
     if (o == null)
     {
         return(null);
     }
     return(new Microsoft.Test.Security.Wrappers.TraceSW(o));
 }
Example #15
0
        /// <summary>
        /// Logs an exception and its context to the error log.
        /// </summary>

        protected virtual void LogException(Exception e, HttpContextBase context)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            //
            // Fire an event to check if listeners want to filter out
            // logging of the uncaught exception.
            //

            ExceptionFilterEventArgs args = new ExceptionFilterEventArgs(e, context);

            OnFiltering(args);

            if (args.Dismissed)
            {
                return;
            }

            //
            // Log away...
            //

            ErrorLogEntry entry = null;

            try
            {
                Error    error = new Error(e, context);
                ErrorLog log   = GetErrorLog(context);
                error.ApplicationName = log.ApplicationName;

                OnLogging(new ErrorLoggingEventArgs(error));

                string id = log.Log(error);
                entry = new ErrorLogEntry(log, id, error);
            }
            catch (Exception localException)
            {
                //
                // IMPORTANT! We swallow any exception raised during the
                // logging and send them out to the trace . The idea
                // here is that logging of exceptions by itself should not
                // be  critical to the overall operation of the application.
                // The bad thing is that we catch ANY kind of exception,
                // even system ones and potentially let them slip by.
                //

                Trace.WriteLine(localException);
            }

            if (entry != null)
            {
                OnLogged(new ErrorLoggedEventArgs(entry));
            }
        }
Example #16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Trace.WriteLine("MainActivity.OnCreate()");

            callback = (Urho3DInterop.SdlCallback)(SdlMain);
            Urho3DInterop.SetExternalSdlMain(callback);
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        }
        private void RenderFakeGridObject(HtmlTextWriter output)
        {
            Guard.ArgumentIsNotNull(output, nameof(output));

            output.Write("<script language=\"javascript\">");
            output.Write($"mygrid{sFullGridId} = new fakeGridObject();");
            output.WriteLine(Resources.txtResourcePlannerRibbonScripts.Replace("#gridid#", sFullGridId));
            output.WriteLine($"mygrid{sFullGridId}._webpartid = \'{ID}\';");

            try
            {
                output.WriteLine($"mygrid{sFullGridId}._modifylist = {reslist.DoesUserHavePermissions(SPBasePermissions.ManageLists).ToString().ToLower()};");
            }
            catch (Exception exception)
            {
                DiagTrace.WriteLine(exception);
                output.WriteLine($"mygrid{sFullGridId}._modifylist = false;");
            }

            try
            {
                output.WriteLine(
                    $"mygrid{sFullGridId}._listperms = {reslist.DoesUserHavePermissions(SPBasePermissions.ManagePermissions).ToString().ToLower()};");
            }
            catch (Exception exception)
            {
                DiagTrace.WriteLine(exception);
                output.WriteLine($"mygrid{sFullGridId}._listperms = false;");
            }

            output.WriteLine($"mygrid{sFullGridId}._shownewmenu = false;");
            output.WriteLine($"mygrid{sFullGridId}._allowedit = true;");

            var view = SPContext.Current.ViewContext.View;

            output.WriteLine($"mygrid{sFullGridId}._listid = \'{HttpUtility.UrlEncode(rcList.ID.ToString()).ToUpper()}\';");
            output.WriteLine($"mygrid{sFullGridId}._viewid = \'{HttpUtility.UrlEncode(view.ID.ToString()).ToUpper()}\';");
            output.WriteLine($"mygrid{sFullGridId}._viewurl = \'{view.ServerRelativeUrl.Replace(" ", "%20")}\';");
            output.WriteLine($"mygrid{sFullGridId}._viewname = \'{view.Title}\';");
            output.WriteLine($"mygrid{sFullGridId}._basetype = \'{reslist.BaseType}\';");
            output.WriteLine($"mygrid{sFullGridId}._templatetype = \'{(int)reslist.BaseTemplate}\';");

            var serverRelativeUrl = resWeb.ServerRelativeUrl;

            output.WriteLine($"mygrid{sFullGridId}._cururl = \'{(serverRelativeUrl == "/" ? string.Empty : serverRelativeUrl)}\';");
            output.WriteLine($"mygrid{sFullGridId}.getUserData = function(item, item2){{return \'0,0,0,0,0,0,0,0,0,0,0,0,0,0\';}}");
            output.WriteLine($"mygrid{sFullGridId}.getSelectedRowId = function(){{return \'0\';}}");
            output.WriteLine($"mygrid{sFullGridId}._excell = \'\';");
            output.WriteLine($"mygrid{sFullGridId}._gridid = \'{sFullGridId}\';");

            var sbForms = ProcessSbForms();

            output.WriteLine($"mygrid{sFullGridId}._formmenus = \"{sbForms}\";");
            output.Write("</script>");
            renderGantt(output);
        }
Example #18
0
        public void Solve()
        {
            var        n   = ri;
            var        P   = Enumerate(n, x => new int[] { ri, ri });
            const long M   = 998244353;
            var        ans = (long)BigInteger.ModPow(2, n, M);

            ans = (ans + M - n - 1) % M;
            var comb = new long[250, 250];

            comb[0, 0] = 1;
            foreach (var i in Rep(220))
            {
                foreach (var j in Rep(220))
                {
                    comb[i, j]         %= M;
                    comb[i + 1, j]     += comb[i, j];
                    comb[i + 1, j + 1] += comb[i, j];
                }
            }
            Debug.WriteLine(ans);
            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    var dx = P[j][0] - P[i][0];
                    var dy = P[j][1] - P[i][1];
                    Debug.WriteLine($"{i} {j} {dx} {dy}");
                    var cnt = 2;
                    var s   = new List <int>()
                    {
                        i, j
                    };
                    for (int k = 0; k < n; k++)
                    {
                        if (k == i || k == j)
                        {
                            continue;
                        }
                        var ex = P[k][0] - P[i][0];
                        var ey = P[k][1] - P[i][1];
                        if (eq(dx, dy, ex, ey))
                        {
                            cnt++; s.Add(k);
                        }
                    }
                    s.Sort();
                    var add = (long)(BigInteger.ModPow(2, cnt, M) + M - cnt - 1) % M;
                    add = (long)(add * BigInteger.ModPow(comb[cnt, 2], M - 2, M) % M);
                    Debug.WriteLine(add);
                    Debug.WriteLine(s.AsJoinedString());
                    ans = (ans + M - add) % M;
                }
            }
            Console.WriteLine(ans);
        }
Example #19
0
 /// <inheritdoc cref="IAmLogger.Warn" />
 public void Warn
 (
     string text
 )
 {
     if (!string.IsNullOrEmpty(text))
     {
         SysTrace.WriteLine(text, "Warn");
     }
 }
Example #20
0
 /// <inheritdoc cref="IAmLogger.Trace" />
 public void Trace
 (
     string text
 )
 {
     if (!string.IsNullOrEmpty(text))
     {
         SysTrace.WriteLine(text, "Trace");
     }
 }
Example #21
0
 /// <inheritdoc cref="IAmLogger.Info" />
 public void Info
 (
     string text
 )
 {
     if (!string.IsNullOrEmpty(text))
     {
         SysTrace.WriteLine(text, "Info");
     }
 }
Example #22
0
 /// <inheritdoc cref="IAmLogger.Fatal" />
 public void Fatal
 (
     string text
 )
 {
     if (!string.IsNullOrEmpty(text))
     {
         SysTrace.WriteLine(text, "Fatal");
     }
 }
Example #23
0
 /// <inheritdoc cref="IAmLogger.Debug" />
 public void Debug
 (
     string text
 )
 {
     if (!string.IsNullOrEmpty(text))
     {
         SysTrace.WriteLine(text, "Debug");
     }
 }
Example #24
0
 /// <inheritdoc cref="IAmLogger.Error" />
 public void Error
 (
     string text
 )
 {
     if (!string.IsNullOrEmpty(text))
     {
         SysTrace.WriteLine(text, "Error");
     }
 }
Example #25
0
        private void WriteLine(Level level, string message, Exception ex = null)
        {
            var msg = string.Format(TEMPLATE, level.ToString().ToUpper(), message);

            if (ex != null)
            {
                msg += Environment.NewLine + ex.ToString();
            }
            OutputTrace.WriteLine(msg);
        }
Example #26
0
        static void SetupInit(Context activity, Assembly resourceAssembly)
        {
            Context = activity;

            ResourceManager.Init(resourceAssembly);

            Color.Accent = GetAccentColor();

            if (!IsInitialized)
            {
                Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c)));
            }

            Device.OS = TargetPlatform.Android;
            Device.PlatformServices = new AndroidPlatformServices();

            // use field and not property to avoid exception in getter
            if (Device.info != null)
            {
                ((AndroidDeviceInfo)Device.info).Dispose();
                Device.info = null;
            }

            // probably could be done in a better way
            var deviceInfoProvider = activity as IDeviceInfoProvider;

            if (deviceInfoProvider != null)
            {
                Device.Info = new AndroidDeviceInfo(deviceInfoProvider);
            }

            var ticker = Ticker.Default as AndroidTicker;

            if (ticker != null)
            {
                ticker.Dispose();
            }
            Ticker.Default = new AndroidTicker();

            if (!IsInitialized)
            {
                Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) });
            }

            int minWidthDp = Context.Resources.Configuration.SmallestScreenWidthDp;

            Device.Idiom = minWidthDp >= TabletCrossover ? TargetIdiom.Tablet : TargetIdiom.Phone;

            if (ExpressionSearch.Default == null)
            {
                ExpressionSearch.Default = new AndroidExpressionSearch();
            }

            IsInitialized = true;
        }
Example #27
0
        public void Solve()
        {
            var n = ri;
            //type A:   i-> ????
            //type B: ->i   ????
            //type C: ->i-> ???
            //type D:   i   ???
            // type C ? type D ??????????????
            //CAAAAAADBBBBBCDCD ??????
            //0???????????
            var AB  = Enumerate(n, x => new long[] { rl, rl });
            var ans = Min(AB.Select(x => x[0]).Sum(), AB.Select(x => x[1]).Sum());
            //??????? N ??????????
            //
            //type A ? type B ????????type C ????????
            //1?????????????????????????
            // ????1: a[n-1]???????a[n] ????(a[n]!=a[n+1]??ok)
            // ????2: a[n-1] ???????a[n+1] ????
            // ????3: a[n-2] ???????a[n] ????
            var a = new List <long>();

            foreach (var i in Rep(n))
            {
                a.Add(AB[i][0] * 1000000 + i);
                a.Add(AB[i][1] * 1000000 + i);
            }
            a.Sort();
            var v    = 0L;
            var used = new int[n];

            for (int i = 0; i < n; i++)
            {
                v += a[i] / 1000000;
                var u = a[i] % 1000000;
                used[u]++;
            }
            if (used.Max() == 2)
            {
                ans = Min(ans, v);
            }
            else
            {
                Debug.WriteLine("po");
                if (a[n - 1] % 1000000 != a[n] % 1000000)
                {
                    ans = Min(ans, v - a[n - 1] / 1000000 + a[n] / 1000000);
                }
                else
                {
                    ans = Min(ans, v - a[n - 1] / 1000000 + a[n + 1] / 1000000);
                    ans = Min(ans, v - a[n - 2] / 1000000 + a[n] / 1000000);
                }
            }
            Console.WriteLine(ans);
        }
        public override void populateGroups(string query, SortedList arrGTemp, SPWeb curWeb)
        {
            Guard.ArgumentIsNotNull(curWeb, nameof(curWeb));
            Guard.ArgumentIsNotNull(arrGTemp, nameof(arrGTemp));
            Guard.ArgumentIsNotNull(query, nameof(query));

            var dataSet      = new DataSet();
            var newTimeSheet = false;

            SPSecurity.RunWithElevatedPrivileges(
                delegate
            {
                var requestedUser = Page.Request["duser"];
                var resourceName  = string.Empty;

                if (!string.IsNullOrWhiteSpace(requestedUser))
                {
                    if (SharedFunctions.canUserImpersonate(username, requestedUser, site.RootWeb, out resourceName))
                    {
                        username = requestedUser;
                    }
                }

                Action <int, string, SqlConnection, DataSet> fillDataSet =
                    (value, cmdText, sql, dataSet1) =>
                {
                    using (var sqlCommand = new SqlCommand(cmdText, sql)
                    {
                        CommandType = CommandType.StoredProcedure
                    })
                    {
                        sqlCommand.Parameters.AddWithValue(IdUserName, username);
                        sqlCommand.Parameters.AddWithValue(IdSiteGuid, site.ID);
                        sqlCommand.Parameters.AddWithValue(IdPeriod, value);

                        using (var dataAdapter = new SqlDataAdapter(sqlCommand))
                        {
                            dataAdapter.Fill(dataSet1);
                        }
                    }
                };

                try
                {
                    SqlConnection(curWeb, fillDataSet, ref dataSet, ref newTimeSheet);
                }
                catch (Exception exception)
                {
                    DiagTrace.WriteLine(exception);
                }

                ProcessDataRow(arrGTemp, curWeb, dataSet, newTimeSheet);
            });
        }
 private void TrySetCheckedProperty(SPWeb web, CheckBox checkBox, string settingKey)
 {
     try
     {
         checkBox.Checked = bool.Parse(CoreFunctions.getConfigSetting(web, settingKey));
     }
     catch (Exception ex)
     {
         SysTrace.WriteLine(ex);
     }
 }
Example #30
0
        /// <summary>
        /// デバッグ用の出力メソッド
        /// </summary>
        /// <param name="format"></param>
        /// <param name="arguments"></param>
        public static void Output(object obj)
        {
            try {
                string head = String.Format("ver{0} ({1})", Version, DateTime.Now);
                string info = String.Format("{0} CLR {1}", Environment.OSVersion, Environment.Version);

                DebugOutput.WriteLine(head);
                DebugOutput.WriteLine(info);
                DebugOutput.WriteLine(obj.ToString());
            }catch {}
            DebugOutput.Write("\r\n");
        }