示例#1
0
 protected void btnSaveSettings_Click(object sender, EventArgs e)
 {
     List<DownloadType> types = new List<DownloadType>();
     foreach (GridViewRow row in spgvSettings.Rows)
     {
         bool flag = ((CheckBox)row.Cells[3].FindControl("chbDelete")).Checked;
         if (flag == false)
         {
             string ext = ((TextBox)row.Cells[0].FindControl("txtExtension")).Text;
             int size = Convert.ToInt32(((TextBox)row.Cells[1].FindControl("txtSize")).Text);
             bool active = ((CheckBox)row.Cells[2].FindControl("chbActive")).Checked;
             DownloadType file = new DownloadType(ext, size, active);
             if (!types.Contains(file))
                 types.Add(file);
         }
     }
     if (types != null)
     {
         ExtState state = DownloadManager.Instance.Save(types);
         switch (state)
         {
             case ExtState.Failed:
                 Helper.AddSPNotification(updSettings, hdnFailed.Value, false);
                 break;
             case ExtState.Success:
                 Helper.AddSPNotification(updSettings, hdnSuccess.Value, false);
                 Refresh();
                 break;
         }
     }
     Refresh();
 }
示例#2
0
 public ExtState Add(DownloadType type)
 {
     ExtState state = ExtState.Failed;
     if (!downloadTypes.Contains(type, new DownloadTypeEqualComparer()))
     {
         downloadTypes.Add(type);
         state = Save(downloadTypes);
     }
     else
         state = ExtState.IsExists;
     return state;
 }
示例#3
0
 protected void btnAddDownload_Click(object sender, EventArgs e)
 {
     DownloadType type = new DownloadType(txtExtension.Text, Convert.ToInt32(txtSize.Text), chbActive.Checked);
     ExtState state = DownloadManager.Instance.Add(type);
     switch (state)
     {
         case ExtState.Failed:
             Helper.AddSPNotification(updSettings, hdnFailed.Value, false);
             break;
         case ExtState.Success:
             Helper.AddSPNotification(updSettings, hdnSuccess.Value, true);
             break;
         case ExtState.IsExists:
             Helper.AddSPNotification(updSettings, string.Format(hdnIsExists.Value, type.Extension), false);
             break;
     }
 }
示例#4
0
 private void GetDownloadTypes()
 {
     List<DownloadType> types = new List<DownloadType>();
     Helper.RunElevated(SPContext.Current.Site.ID, SPContext.Current.Site.RootWeb.ID, delegate(SPWeb elevatedWeb)
     {
         try
         {
             string[] fileTypes = elevatedWeb.Properties[Content.SPFileTypes].ToLower().Split(';');
             string[] fileSizes = elevatedWeb.Properties[Content.SPFileSizes].ToLower().Split(';');
             string[] actives = elevatedWeb.Properties[Content.SPFileTypesActive].ToLower().Split(';');
             if (fileSizes != null && fileTypes != null)
                 if (fileTypes.Length == fileSizes.Length)
                     for (int i = 0; i < fileTypes.Length - 1; i++)
                     {
                         DownloadType file = new DownloadType(fileTypes[i], Convert.ToInt32(fileSizes[i]), Convert.ToBoolean(actives[i]));
                         if (!types.Contains(file, new DownloadTypeEqualComparer()))
                             types.Add(file);
                     }
         }
         catch (Exception ex)
         {
         }
     });
     if (types.Count > 0)
     {
         downloadTypes.Clear();
         downloadTypes.AddRange(types);
     }
 }